import http from '../../http'
// 初始化页面
const initroles = async () => {
    let data = await http.get('roles')
    return data
}
// 添加数据
const add = async (obj) => {
    let data = await http.post('roles', obj)
    return data
}
// 编辑数据回填
const updata = async (obj) => {
    let data = await http.get(`roles/${obj.id}`)
    return data
}
// 编辑数据提交
const updataction = async (obj) => {
    let data = await http.put(`roles/${obj.roleId}`, obj)
    return data
}
// 编辑数据提交
const deleteitem = async (obj) => {
    let data = await http.delete(`roles/${obj.id}`)
    return data
}
// 编辑权限分配
const quanxian = async () => {
    let data = await http.get(`rights/tree`)
    return data
}
// 编辑权限分配
const quanxiansubmit = async (str, id) => {
    let data = await http.post(`roles/${id}/rights`, { rids: str })
    return data
}
// 权限删除
const deletequanxian = async (obj) => {
    let data = await http.delete(`roles/${obj.roleId}/rights/${obj.rightId}`)
    return data
}
export { initroles, add, updata, updataction, deleteitem, quanxian, quanxiansubmit,deletequanxian }